<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
  
  <head>
    
    <%@ include file="/WEB-INF/include/meta.jsp"%>
    <%@ include file="/WEB-INF/include/css.jsp"%>
    <title>人马君</title>
  </head>
  <!-- end header -->
  <body>
    <div class="page-group">
      <div class="page page-current bg-light-gray">
        <nav class="bar bar-tab punch-card-bar">
          <a class="tab-item external" href="${ctx.host}/courses/${monthlyCourseware.id}/batches/${persist.batchCourseware(monthlyCourseware.id).id}/units">
            <span class="icon icon-today"></span>
            <span class="tab-label">今日</span>
          </a>
          <a class="tab-item external active" href="${ctx.host}/courses">
            <span class="icon icon-lesson"></span>
            <span class="tab-label">课程</span>
          </a>
          <a class="tab-item external" href="${ctx.host}/profile">
            <span class="icon icon-profile"></span>
            <span class="tab-label">我的</span>
          </a>
        </nav>
        
        <div class="content">
          <div class="list-block media-list course-list no-margin">
            <ul>
              <c:forEach var="batch" items="${batches}">
                <li>
                  <c:set var="signinUrl" value="${ctx.host}/courses/${monthlyCourseware.id}/batches/${batch.id}"/>
                  <c:set var="finishUrl" value="${ctx.host}/courses/${monthlyCourseware.id}/batches/${batch.id}/finish-courseware"/>
                  <a href="${batch.status.signining ? signinUrl : batch.status.finished ? finishUrl : 'javascript:void(0);'}" 
                     class="item-content ${batch.status.prepare ? 'lock' : ''}">
                    <div class="item-media">
                      <img src="${cloud.prod}/${monthlyCourseware.courseRound.course.cover}-qrcode" class="course-cover" onerror="this.src='${ctx.resource}/image/error.jpg'">
                      <c:if test="${batch.status.prepare}"><div class="lock-wrap"></div></c:if>
                    </div>
                    <div class="item-inner">
                      <div class="title-wrap">
                        <div class="item-title-row">
                          <div class="item-title ellipsis">${batch.template.name}</div>
                        </div>
                        <div class="item-subtitle ellipsis">第${batch.template.sorting}周</div>
                      </div>
                      <div class="button-wrap" >
                        <button class="button punch-btn button-yellow pull-right ${batch.status.prepare ? 'start-punch hasclock' : batch.status.signining ? 'start-punch' : ''}">${batch.status.description}</button>
                      </div>
                    </div>
                  </a>
                </li>
              </c:forEach>
            </ul>
          </div>
        </div>
        
      </div>
    </div>
    
    <%@ include file="/WEB-INF/include/script.jsp"%>
    <d:resource root="${ctx.resource}/build" type="script" src="js/page/course/batch-course.js" />
    <script type="text/javascript">
      require(['page/course/batch-course'], function(page) {
        page.init()
      })
    </script>
    
  </body>
</html>